#ifndef __loconet_h
#define __loconet_h


// 2 byte message opcodes
// FORMAT = <opcode>,<checksum>
/////////////////////////////////////////////////////////////////////////

// These messages require no responses
#define IDLE 0x85			// Force idle state, broadcast emergency
#define GPON 0x83			// Global power on request
#define GPOFF 0x82			// Global power off request
#define BUSY 0x81			// Master busy code

// 4 byte message opcodes
// FORMAT = <opcode>,<arg1>,<arg2>,<checksum>
/////////////////////////////////////////////////////////////////////////

// These messages require responses
#define LOCO_ADR 0xBF		// Request a loconet address
#define SW_ACK 0xBD			// Request a switch with acknowledge function
#define SW_STATE 0xBC		// Request state of switch
#define RQ_SL_DATA 0xBB		// Request slot data/status block
#define MOVE_SLOTS 0xBA		// Move slot src to dest, src=arg1, dest=arg2
#define LINK_SLOTS 0xB9		// Links slot arg1 to slot arg2
#define UNLINK_SLOTS 0xB8	// Unlink slot arg1 from slot arg2

// These messages require no responses
#define CONSIST_FUNC 0xB6	// Set FUNC bits in a CONSIST uplink element
#define SLOT_STAT1 0xB5		// Write slot stat1, arg1=slot, arg2=stat1
#define LONG_ACK 0xB4		// Long acknowledge, used as a response
#define INPUT_REP 0xB2		// General sensor input codes
#define	SW_REP 0xB1			// Turnout sensor state report
#define SW_REQ 0xB0			// Request switch function

#define LOCO_SND 0xA2		// Set slot sound functions
#define LOCO_DIRF 0xA1		// Set slot dir, F0-4 state
#define LOCO_SPD 0xA0		// Set slot speed

// Variable byte message opcodes
// FORMAT = <opcode>,<count>,<arg2>,<arg3>,...,<arg(count-3)>,<checksum>
/////////////////////////////////////////////////////////////////////////

#define WR_SL_DATA 0xEF		// Write slot data, 10 bytes of data
#define SL_RD_DATA 0xE7		// Slot data retur, 10 bytes of data

#define PEER_XFER 0xE5		// Move 8 bytes PEER to PEER, SRC->DST
#define IMM_PACKET	0xED	// Send n-byte packet immediately

// Slot Speeds
/////////////////////////////////////////////////////////////////////////
#define SPEED_STOP 0x00		// Speed 0, stop inertially
#define SPEED_EMER_STOP 0x01// Speed 0 emergency stop
#define SPEED_MAX 0x7E		// MAX speed


#endif

